package com.yaozheng.vocationaltraining.service.impl;

import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.EBean;

import com.yaozheng.vocationaltraining.iview.ITokenBaseView;
import com.yaozheng.vocationaltraining.service.PaperCatalogService;
import com.yaozheng.vocationaltraining.utils.Constants;
import com.yaozheng.vocationaltraining.utils.ErrorUtils;
import com.yaozheng.vocationaltraining.utils.http.okhttp.OkHttpClientManager;

@EBean
public class PaperCatalogServiceImpl implements PaperCatalogService {
	ITokenBaseView iTokenBaseView;

	@Override
	public void init(ITokenBaseView iTokenBaseView) {
		this.iTokenBaseView = iTokenBaseView;
	}

	/**
	 * 每日一测
	 */
	@Background
	@Override
	public void quizzesList(int offset) {
		try {
			OkHttpClientManager.getInstance().get(
					Constants.ROOTURL + "/exam/common/list?offset=" + offset,
					iTokenBaseView.getToken(), iTokenBaseView);
		} catch (Exception e) {
			ErrorUtils.outErrorLog(e);
			if (iTokenBaseView.isResponseResult()) {
				iTokenBaseView
						.responseError(ErrorUtils.SERVER_CONNECTION_ERROR);
			}

		}
	}

	/**
	 * 考试列表
	 */
	@Background
	@Override
	public void examList(int offset) {
		try {
			OkHttpClientManager.getInstance().get(
					Constants.ROOTURL + "/exam/main/list?offset=" + offset,
					iTokenBaseView.getToken(), iTokenBaseView);
		} catch (Exception e) {
			ErrorUtils.outErrorLog(e);
			if (iTokenBaseView.isResponseResult()) {
				iTokenBaseView
						.responseError(ErrorUtils.SERVER_CONNECTION_ERROR);
			}

		}
	}

}
